import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
import { getWeekMonthQuarterYear } from '/@/utils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: 'id',
    dataIndex: 'id',
    width: 80,
    ifShow: false,
  },
  {
    title: '周期名称',
    dataIndex: 'periodName',
    width: 150,
    align: 'center',
  },
  {
    title: '周期编码',
    dataIndex: 'periodCode',
    width: 150,
    align: 'center',
  },
  {
    title: '开始日期',
    dataIndex: 'beginDate',
    align: 'center',
    width: 150,
  },
  {
    title: '结束日期',
    dataIndex: 'endDate',
    align: 'center',
    width: 150,
  },
  {
    title: '创建日期',
    dataIndex: 'sysCreateDate',
    align: 'center',
    width: 150,
  },
  {
    title: '备注',
    dataIndex: 'remark',
    width: 150,
    align: 'center',
  },
];
//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    field: 'periodName',
    label: '周期名称',
    component: 'Input',
    colProps: { span: 8 },
  },
  {
    field: 'periodCode',
    label: '周期编码',
    component: 'Input',
    colProps: { span: 8 },
  },
];
//表单数据
export const formSchema: FormSchema[] = [
  {
    field: 'periodCode',
    label: '周期编码',
    component: 'DatePicker',
    required: true,
    componentProps: {
      valueFormat: 'YYYY',
      placeholder: '请选择周期编码',
      picker: 'year',
    },
    dynamicDisabled: ({ values }) => {
      return !!values.id;
    },
  },
  {
    field: 'remark',
    label: '备注',
    component: 'InputTextArea',
    componentProps: {
      rows: 5,
    },
    dynamicRules: () => {
      return [
        {
          validator: (_, value) => {
            if (null != value && value.length && value.length > 500) {
              return Promise.reject('备注字数不能超过500');
            }
            return Promise.resolve();
          },
        },
      ];
    },
  },
	// TODO 主键隐藏字段，目前写死为ID
	{
	  label: '',
	  field: 'id',
	  component: 'Input',
	  show: false
	},
];

// 高级查询数据
export const superQuerySchema = {
  periodCode: {title: '周期编码',order: 0,view: 'text', type: 'string',},
  periodName: {title: '周期名称',order: 1,view: 'text', type: 'string',},
  beginDate: {title: '开始日期',order: 2,view: 'text', type: 'string',},
  endDate: {title: '结束日期',order: 3,view: 'text', type: 'string',},
  periodType: {title: '周期频度',order: 4,view: 'text', type: 'string',},
  remark: {title: '描述',order: 5,view: 'textarea', type: 'string',},
  displayOrder: {title: '显示排序',order: 6,view: 'number', type: 'number',},
  parentCode: {title: '父周期编码',order: 7,view: 'text', type: 'string',},
  sysCreatorId: {title: '创建人',order: 8,view: 'text', type: 'string',},
  sysCreateDate: {title: '创建日期',order: 9,view: 'datetime', type: 'string',},
  sysUpdatorId: {title: '修改人',order: 10,view: 'text', type: 'string',},
  sysUpdateDate: {title: '修改日期',order: 11,view: 'datetime', type: 'string',},
  sysDeptId: {title: '归属部门标识',order: 12,view: 'text', type: 'string',},
  sysCompanyId: {title: '归属单位标识',order: 13,view: 'text', type: 'string',},
  isRelease: {title: '是否归档',order: 14,view: 'text', type: 'string',},
  levelCode: {title: '直接父周期',order: 15,view: 'text', type: 'string',},
};

/**
* 流程表单调用这个方法获取formSchema
* @param param
*/
export function getBpmFormSchema(_formData): FormSchema[]{
  // 默认和原始表单保持一致 如果流程中配置了权限数据，这里需要单独处理formSchema
  return formSchema;
}